#include<bits/stdc++.h>
using namespace std;

int pos[100010],ans,ans1;

struct cars{
    double d,v,a;
    int l=-1,r=-1;
}cs[100010];

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--){
        int n,m,L,V;
        ans = ans1 = 0;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++) scanf("%lf%lf%lf",&cs[i].d,&cs[i].v,&cs[i].a);
        for(int i=1;i<=m;i++) scanf("%d",pos+i);
        for(int i=1;i<=n;i++){
            if(cs[i].a>=0){
                for(int j=1;j<=m;j++){
                    if(cs[i].d>pos[j]||cs[i].d>L) continue;
                    if(cs[i].a==0&&cs[i].v>V){
                        cs[i].l=pos[j];
                        cs[i].r=pos[m];
                        break;
                    }
                    else break;
                    double s = pos[j]-cs[i].d;
                    double res = sqrt(cs[i].v*cs[i].v+2*cs[i].a*s);
                    if(double(res) > double(V)){
                        cs[i].l=pos[j];
                        cs[i].r=pos[m];
                        break;
                    }
                }
            }
            else{
                if(cs[i].v<V) break;
                int p = lower_bound(pos+1,pos+1+m,cs[i].d)-pos;
                double res = sqrt(cs[i].v*cs[i].v+2*cs[i].a*(pos[p]-cs[i].d));
                if(double(res) <= double(V)) break;
                ans++;
                cs[i].l = pos[p];
                bool flag = 1;
                for(int j=p;j<=m;j++){
                    double res = sqrt(cs[i].v*cs[i].v+2*cs[i].a*(pos[j]-cs[i].d));
                    if(double(res) <= double(V)){
                        cs[i].r = pos[j];
                        flag = 0;
                        break;
                    }
                }
                if(flag) cs[i].r = pos[m];
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}